﻿<Window x:Class="WpfClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="600" WindowStartupLocation="CenterScreen">
    <Grid>
        <Grid.Resources>
            <Style TargetType="ListViewItem" x:Key="itemStyle">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="IsSelected" Value="True" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
            <TextBlock Text="Subscribers Totali:" VerticalAlignment="Center"/>
            <TextBlock Text="{Binding Subscribers.Count}" Margin="15,0" VerticalAlignment="Center" FontWeight="Bold" FontSize="15"/>
            <Button Height="32" Margin="5" Command="{Binding AddCommand}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Add Listener" VerticalAlignment="Center"/>
                    <Image Source="iconAdd.png" VerticalAlignment="Center" Margin="5,0"/>
                </StackPanel>
            </Button>
        </StackPanel>
        <DockPanel Grid.Row="1">
            <ListView ItemsSource="{Binding Subscribers}" IsSynchronizedWithCurrentItem="True"
                       ItemContainerStyle="{StaticResource itemStyle}">
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="FrameworkElement.Visibility" Value="Collapsed"/>
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridViewColumn Width="200" DisplayMemberBinding="{Binding ID}">
                        </GridViewColumn>
                        <GridViewColumn Width="100" DisplayMemberBinding="{Binding Price}">
                        </GridViewColumn>
                        <GridViewColumn Width="150" DisplayMemberBinding="{Binding Delay}">
                        </GridViewColumn>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Height="32" Command="{Binding 
                                        RelativeSource={RelativeSource AncestorType=ListView}, 
                                        Path=DataContext.CancelCommand}">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Unsubscribe" VerticalAlignment="Center"/>
                                            <Image Source="iconClose.png" VerticalAlignment="Center" Margin="5,0"/>
                                        </StackPanel>
                                    </Button>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
    </Grid>
</Window>
